package com.amado.course07Array;

//10.     有一个数组如下: int[] array = {8, 11, 21, 91, 23, 891, 999, 888, 55, 25}, 请将数组的元素全部向后
//移动三位。然后再打印所有数组元素。
//得到结果：{888, 55, 25,8, 11, 21, 91, 23, 891, 999}
public class Array10 {
	public static void main(String[] args) {
		int[] array = { 8, 11, 21, 91, 23, 81, 999, 888, 55, 25 };
		int moveLength = 5;
		
		int arrayLength = array.length;// 10
		// 控制移动几次
		for (int i = 0; i < moveLength; i++) {
			// 10-3=7:array[7]=888
			int lastValue = array[arrayLength - moveLength + i];
			for (int j = arrayLength - moveLength + i; j > i; j--) {
				// array[10-3-0]=array[7]
				array[j] = array[j - 1];
			}
			array[i] = lastValue;
		}
		for (int temp : array) {
			System.out.print(temp + " ");
		}
	}
}
